package net.oschina.simpleplus.erpc.producer;

import java.util.concurrent.ConcurrentHashMap;

import net.oschina.simpleplus.erpc.core.ERpcResp;
import net.oschina.simpleplus.erpc.core.ERpcResultEntity;

public class ERpcResultCache {

	private ConcurrentHashMap<String, ERpcResp> erpcResps = new ConcurrentHashMap<>();
	
	public void setValue(String msgId, ERpcResultEntity eRpcResultEntity){
		ERpcResp eRpcResp = erpcResps.remove(msgId);
		if(eRpcResp!=null){
			eRpcResp.setValue(eRpcResultEntity);
		}
	}

	public ERpcResp put(String msgId, Class<?> returnType){
		ERpcResp value = new ERpcResp(msgId, returnType);
		erpcResps.put(msgId, value);
		return value;
	}
}
